<!DOCTYPE html>
<html lang="en">

<head>
    <title>ReportBro Demo Invoice</title>
    <meta charset="utf-8" />
    <link href="reportbro.css" rel="stylesheet" type="text/css" />
    <script src="reportbro.js"></script>
    <style>
        html,
        body {
            margin: 0;
            padding: 0;
        }
    </style>
</head>

<body>
    <div id="reportbro"></div>

    <script type="text/javascript">
        function saveReport() {
            const reportData = rb.getReport();
            console.log(JSON.stringify(reportData));
            return;
            axios.put('url', reportData
            ).then(function (response) {
                // report definition saved successfully,
                // set modified flag to false to disable save button
                rb.setModified(false);
            })
                .catch(function (error) {
                    alert('saving report failed');
                });
        }


        const rb = new ReportBro(document.getElementById('reportbro'), {
            //remove reportServerUrl if you want to use the default report server for a quick start
            reportServerUrl: '/api/method/frappe_study.frappestudy.report_server.run',
            saveCallback: saveReport,
            menuShowButtonLabels: true
        });
        //rb.load(report);
        fetch('/api/method/frappe_study.frappestudy.print_service.get_doc_withmeta')
            .then(response => response.json())
            .then(data => {
                // 使用解析后的对象
                console.log(data);
                rb.load(data.message);
            })
            .catch(error => console.error('Error:', error)); 
    </script>
</body>

</html>